package com.qinsoft.frame.taobao.recom;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.directwebremoting.WebContextFactory;

import com.qinsoft.business.recom.bean.Recom;
import com.qinsoft.business.recom.bean.RecomItem;
import com.qinsoft.business.recom.dao.RecomDao;
import com.qinsoft.frame.common.UserUtil;

public class RecomService 
{
    private String sessionId = WebContextFactory.get().getSession().getId();
    private String nick = UserUtil.getInstance().getUserInfo(sessionId).getNick();
    /**
     * 保存橱窗计划
     */
    public void savePlan(Recom recom)
    {
        RecomDao recomDao = new RecomDao();
        recom.setNick(nick);
        recomDao.save(recom);
    }
    /**
     * 获取橱窗计划
     */
    public Recom getPlan()
    {
        RecomDao recomDao = new RecomDao();
        return recomDao.select(nick);
    }
    /**
     * 保存橱窗商品
     */
    public void saveItem(Recom recom, List<RecomItem> recomItems, List<RecomItem> removeItems)
    {
        RecomDao recomDao = new RecomDao();
        recomDao.saveItem(recom, recomItems, nick);
    }
    /**
     * 获取橱窗商品
     */
    public Map<String, Object> getItem(String type)
    {
        RecomDao recomDao = new RecomDao();
        Map<String, Object> map = new HashMap<String, Object>();
    	List<RecomItem> list = recomDao.selectItem(nick,type);
    	map.put("list", list);
    	map.put("numIids", list.toString());
    	return map;
    }
}
